package com.mycompany.lctwitter.action.message;

import java.util.List;

import javax.annotation.Resource;

import com.mycompany.lctwitter.action.AbstractAction;
import com.mycompany.lctwitter.persist.model.Location;
import com.mycompany.lctwitter.persist.model.Message;
import com.mycompany.lctwitter.persist.model.User;
import com.mycompany.lctwitter.persist.service.MessageService;
import com.mycompany.lctwitter.persist.service.UserService;

public class ListUserAction extends AbstractAction {

    private static final long serialVersionUID = 9216421633628524287L;

    private List<Message> messages;

    private long userId;

    private User user;

    private Location location;

    @Resource
    private MessageService messageService;

    @Resource
    private UserService userService;

    public List<Message> getMessages() {
        return messages;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public Location getLocation() {
        return location;
    }

    public User getUser() {
        return user;
    }

    @Override
    public String execute() {
        messages = messageService.listByUser(userId);
        user = userService.find(userId);
        return SUCCESS;
    }
}
